/*     */ package com.qmsk.business.member.memberConsumeRecord.controller;
/*     */ 
/*     */ import com.qmsk.business.member.memberConsumeRecord.dao.MemberConsumeRecordDAO;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import java.util.Date;
/*     */ import java.util.List;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/consumeRec"})
/*     */ public class MemberConsumeRecordController
/*     */ {
/*  34 */   private static final Logger logger = Logger.getLogger(MemberConsumeRecordController.class);
/*     */ 
/*     */   @Autowired
/*     */   private MemberConsumeRecordDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/billNo/{billNo}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListBillNo(HttpServletRequest request, HttpServletResponse response, @PathVariable("billNo") String billNo)
/*     */   {
/*     */     try
/*     */     {
/*  53 */       GsonEbRst gsonEbRst = this.dao.getGsonOfBillNo(billNo);
/*  54 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  56 */       logger.error(e);
/*  57 */       ResponseUtils.setErrorMsgResponse(
/*  58 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/billNo/memberId/{billNo}/{memberId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListBillNoMemberId(HttpServletRequest request, HttpServletResponse response, @PathVariable("billNo") String billNo, @PathVariable("memberId") Long memberId)
/*     */   {
/*     */     try
/*     */     {
/*  77 */       GsonEbRst gsonEbRst = this.dao.getGsonOfBillNoMemberId(billNo, memberId);
/*     */ 
/*  83 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  85 */       logger.error(e);
/*  86 */       ResponseUtils.setErrorMsgResponse(
/*  87 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/list"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insertList(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/* 104 */       int nResult = 0;
/* 105 */       ParserDataSetJson p = new ParserDataSetJson(request.getParameter("data"));
/* 106 */       if (p.getListInsertRows() != null) {
/* 107 */         for (int i = 0; i < p.getListInsertRows().size(); ++i) {
/* 108 */           GsonHeadOneRow r = (GsonHeadOneRow)p.getListInsertRows().get(i);
/* 109 */           r.addHeadData("date", new Date());
/*     */         }
/*     */       }
/* 112 */       nResult = this.dao.applyUpdates(p);
/* 113 */       if (nResult > 0)
/* 114 */         DbConnection.commit();
/*     */       else {
/* 116 */         DbConnection.rollback();
/*     */       }
/* 118 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 119 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 120 */         response);
/*     */     } catch (Exception e) {
/* 122 */       DbConnection.rollback();
/* 123 */       logger.error(e);
/* 124 */       ResponseUtils.setErrorMsgResponse(
/* 125 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 126 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 142 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 144 */       String[] strParams = id.split(",");
/* 145 */       int nResult = this.dao.deleteParams(strParams);
/* 146 */       DbConnection.commit();
/* 147 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 148 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 149 */         response);
/*     */     } catch (Exception e) {
/* 151 */       DbConnection.rollback();
/* 152 */       logger.error(e);
/* 153 */       ResponseUtils.setErrorMsgResponse(
/* 154 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 155 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 171 */     String id = request.getParameter("id");
/* 172 */     String sGsonInData = request.getParameter("data");
/*     */     try {
/* 174 */       GsonHeadOneRow g = GsonHeadOneRow.jsonStrToObject(sGsonInData);
/* 175 */       if (g == null) {
/* 176 */         ResponseUtils.setErrorMsgResponse(
/* 177 */           RequestUtils.getReadJsonDataErrorMessage(request), 
/* 178 */           response);
/*     */       } else {
/* 180 */         int nResult = this.dao.updateJsonOneRow(g, id);
/* 181 */         ResponseUtils.setSqlResultResponse(nResult, 
/* 182 */           RequestUtils.getSqlUpdateErrorMessage(sGsonInData, request), 
/* 183 */           response);
/*     */       }
/* 185 */       DbConnection.commit();
/*     */     } catch (Exception e) {
/* 187 */       DbConnection.rollback();
/* 188 */       logger.error(e);
/* 189 */       ResponseUtils.setErrorMsgResponse(
/* 190 */         RequestUtils.getSqlUpdateErrorMessage(sGsonInData, request) + ":" + 
/* 191 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.member.memberConsumeRecord.controller.MemberConsumeRecordController
 * JD-Core Version:    0.5.3
 */